<%@ page import="dbOperation.DbSelect" %>
<%@ page import="java.util.List" %>
<%@ page import="library.Book" %><%--
  Created by IntelliJ IDEA.
  User: v
  Date: 17-5-20
  Time: 下午4:02
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>查看我的图书馆</title>
</head>
<body>
<div class="lb">
    <table align="center" border="1" width="600">
        <tr>
            <td><b>ID</b></td>
            <td><b>图书名称</b></td>
            <td><b>价格</b></td>
            <td><b>数量</b></td>
            <td><b>作者</b></td>
        </tr>
        <%
            int currentPage=1;
            try {
                currentPage=Integer.parseInt((String) request.getParameter("page"));
            }catch (Exception ex){
                //如遇错误，则跳转到错误处理页
                response.sendRedirect("/exception/exception.html");
            }

            //获取相关的书单
            List<Book> list=DbSelect.books(currentPage);

            //打印这整个表
            for (Book book:list) {
        %>
        <tr>
            <td><%=book.getId()%></td>
            <td><%=book.getName()%></td>
            <td><%=book.getPrice()%></td>
            <td><%=book.getAmount()%></td>
            <td><%=book.getAuthor()%></td>
        </tr>
        <%
            }
        %>
    </table>

    <br>
    <br>
    <hr>
    <table align="center">
        <tr>
            <td>
                <%=request.getAttribute("bar")%>
            </td>
        </tr>
    </table>

    <input type="button" value="返回首页" onclick="location.href='/index.jsp'" style="position: absolute;bottom: 20%;left: 45%;">
</div>
</body>
</html>
